package com.cyw.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.cyw.pojo.Role;
import com.cyw.pojo.User;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author cyw
 * @since 2022-10-30
 */
public interface UserMapper extends BaseMapper<User> {

    @Select("select * from user where name = #{name}")
    public User findUserByName(String username);

    // 获取用户所拥有的角色
    @Select("select * from  role where role_code in(select role_code from user_role where username = #{userName})")
    public Set<Role> getUserRoles(String username);
}
